package cn.bluethink.eguan.okrtask.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Id;
import javax.persistence.Table;

import cn.bluethink.eguan.model.core.EgUser;
import cn.bluethink.eguan.model.okrtask.EgTaskKR;
/**
 * 工作任务关键结果实体
 * 
 * @title 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.1.0
 * @describe 
 * @author liuxn
 * @date  2018年10月19日
 */
@Table(name = "eg_taskkr")
public class EgTaskKREntity implements Serializable{
	private static final long serialVersionUID = 1918569723614537520L;

	/**
	 * 主键Id
	 */
	@Id
	private Long krid;
	
	/**
	 * 任务Id
	 */
	private Long tid;
	
	/**
	 * 关键项内容
	 */
	private String content;
	
	/**
	 * 被指派人Id
	 */
	private Long douid;
	
	/**
	 * 关键项截止日期
	 */
	private Date etime;
	
	/**
	 * 关键项完成日期
	 */
	private Date ftime;
	
	/**
	 * 关键项备注
	 */
	private String remark;
	
	/**
	 * 对关键项完成情况的评价
	 */
	private String evaluate;
	
	/**
	 * 对关键项完成情况打分，百分制
	 */
	private Integer score;
	
	/**
	 * 关键项状态
	 */
	private Integer status;
	
	/**
	 * 关键项排序
	 */
	private Integer sort;
	
	/**
	 * 创建时间
	 */
	private Date ctime;

	public EgTaskKREntity() {
		
	}
	
	/**
	 * 模型转实体
	 * @param taskkr
	 * @param bcreate
	 */
	public EgTaskKREntity(EgTaskKR taskkr, boolean bcreate) {
		this.krid = taskkr.getId();
		this.tid = taskkr.getTid();
		this.content = taskkr.getKrContent();
		this.evaluate = taskkr.getEvaluate();
		this.status = taskkr.getStatus();
		this.remark = taskkr.getRemark();
		this.etime = taskkr.getEtime();
		this.ftime = taskkr.getFtime();
		this.douid = taskkr.getDouser() != null && taskkr.getDouser().getId() != null && taskkr.getDouser().getId() > 0 ? taskkr.getDouser().getId() : null;
		if(bcreate) {
			this.ctime = new Date();
			this.score = taskkr.getScore() == null ? 0 : taskkr.getScore();
		}
		this.score = taskkr.getScore();
	}
	
	/**
	 * 实体转模型
	 * @return
	 */
	public EgTaskKR createKeyResult() {
		EgTaskKR taskkr = new EgTaskKR();
		taskkr.setId(krid);
		taskkr.setTid(tid);
		taskkr.setKrContent(content);
		taskkr.setRemark(remark);;
		taskkr.setEtime(etime);
		taskkr.setEvaluate(evaluate);
		taskkr.setScore(score);
		taskkr.setStatus(status);
		taskkr.setFtime(ftime);
		if(douid == null || douid == 0) douid = 0L;
		taskkr.setDouser(new EgUser(douid, null, null));
		return taskkr;
	}
	
	public Long getKrid() {
		return krid;
	}

	public void setKrid(Long krid) {
		this.krid = krid;
	}

	public Long getTid() {
		return tid;
	}

	public void setTid(Long tid) {
		this.tid = tid;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getEtime() {
		return etime;
	}

	public void setEtime(Date etime) {
		this.etime = etime;
	}

	public String getEvaluate() {
		return evaluate;
	}

	public void setEvaluate(String evaluate) {
		this.evaluate = evaluate;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Date getCtime() {
		return ctime;
	}

	public void setCtime(Date ctime) {
		this.ctime = ctime;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public Long getDouid() {
		return douid;
	}

	public void setDouid(Long douid) {
		this.douid = douid;
	}

	public Date getFtime() {
		return ftime;
	}

	public void setFtime(Date ftime) {
		this.ftime = ftime;
	}
	
	
}
